<?php
/**
 * SocialEngine
 *
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 * @version    $Id: Club.php 2010-09-07 16:05 idris $
 * @author     Idris
 */

/**
 * @category   Application_Extensions
 * @package    Like
 * @copyright  Copyright Hire-Experts LLC
 * @license    http://www.hire-experts.com
 */

class Like_Model_Club extends Core_Model_Item_Abstract
{
	public function enable($flag = true)
	{
		$this->active = $flag ? 1 : 0;
		$this->save();
	}
	
	public function getLikes($params = array())
	{
		if (empty($params['club_id'])){
			 $params['club_id'] = $this->club_id;
		}
		
		return Engine_Api::_()->like()->getLikeUsersTable()->getLikes($params);
	}
	
	public function getSubject()
	{
		return Engine_Api::_()->getItem($this->object, $this->object_id);
	}
	
	protected function _delete()
	{
	  $likeTable = Engine_Api::_()->getDbTable('likes', 'like');
	  $name0 = $likeTable->info('name');
	  
		$db = $this->getTable()->getAdapter();
		$db->delete($name0, "like_club_id = {$this->club_id}");
		
		parent::_delete();
	}
}